<@page currentChannel="JOB" title="简历预览" useheader="compact" 
	assets=["/lib/jquery/jquery.js",
			"/css/site/base-form.css",
			"/up/resume/css/global.css",
			"/up/resume/css/cover-letter.css",
			"/up/resume/css/preview.css",
			"/up/position-invitation/css/invitation.css",
			"/css/modules/register-pop.css",
			'/css/layout/fullwidth.css',
			'/css/channels/network.css',
			'/up/position-invitation/css/position-invitation.css',
			'/up/yaoyue/css/company-hrmail.css',
			'/css/pages/company-hrmail.css',
			'/css/site/base-form.css',
			"/up/position-invitation/js/basic-incormation.js",
			"/js/jquery.tips.js",
			"/lib/jquery/jquery.color.js",
			"/js/jquery.linkup.js", 
			"/js/jquery.inputchecknormal.js",
			'/js/jquery.freemailcheck.js',
			"/up/dic/js/intention.js",
			'/js/jquery.formvalidate.js',
			'/js/jquery.formvalidatefn.js',
			'/up/position-invitation/js/misc.js',
			'/up/mathan/mathan.js',
			"/css/site/base-form.css",
			"/css/components/matchbox.css", 
			"/up/resume/css/global.css",
			"/up/resume/css/resume.css",
			"/up/job-project-2013/css/verify-phone.css",
			"/js/jquery.formvalidatefn.js",
			"/js/jquery.ajax-limit.js", 
			"/js/jquery.formvalidate.js", 
			"/js/jquery.linkup.js", 
			"/up/resume/js/jquery.ui.core.js",
			"/up/resume/js/jquery.ui.widget.js",
			"/up/resume/js/jquery.ui.mouse.js",
			"/up/resume/js/jquery.ui.sortable.js",
				"/up/campus-recruitment/css/navigation.css",
				"/up/recommend/css/intention.css",
				"/js/jquery.pickpad.js",
				"/js/jquery.interactive.js",
			"/up/job-project-2013/js/verify-phone.js"]>
			
<#--"/up/resume/js/misc.js",-->  
<div id="content" class="clearfix">
<div id="inviter-corp-fragment">
    <div class="basic-banner clearfix">
        <span><img alt="${(job.corpName)!""}" src="http://${configs['domains.assets']}/images/club/logo-big.gif"></span>
        <h2 title="${(job.corpName)!""}"><@cutWords words =(job.corpName!"") length =22 suffix = ""/><#if id?? && id !=0> <em class="g9">|</em> <em class="txtColor">职位邀请函</em></#if></h2>
    </div>
</div>

 
    <div class="dj-main dj-nosubnav2">
        <div class="letter-main">
            <form name="div-form" id="div-form" >
                <input type="hidden" name="id" value="${id!""}" id="id">
                <input type="hidden" name="jid" value="${jid!""}" id="jid_1">
                <div class="main-head">
                    <div class="invite-title2" <#if !inviter??>style="padding-left:80px;"</#if>>
                        <#if inviter??>
                            <div id="invite-info" >
                                <div class="invite-con" style="backgroupd:none repeat scroll 0 0,width:800px">
                                        <div class="pic">
                                            <a target="_blank" href="${inviter.homepage()!"#"}"><img src="${inviter.getAvatarUrl("s")}" width="50"></a>
                                        </div>
                                        <div class="invite-people-info">
                                            <h3 class="yahei">${(inviter.name)!}</h3>
                                            <p><#if inviter.identity == 1>${inviter.position!}<#elseif inviter.identity == 0>${inviter.majorName!}</#if></p>
                                        </div>
                                </div>
                            </div>
                        </#if>

                        <div class="invite-tips">
                            <h4 class="bt yahei">
                                    	填写联系方式并提交职位意向，我们会尽快与您联系
                            </h4>
                        </div>
                        <span class="basic-icon"></span>
                    </div>
                </div>
            </form>
        </div>
    </div> 

<div class="dj-main2 dj-nosubnav">
   <div >
   		<div style="text-align:right">
         	<#if !(userBase??)>当前状态为未登录。已有大街账号？<a href="http://www.dajie.com/account/login"> 快速登录 </a>获取在线简历 </#if>
   		</div>
   	<br/>
   <form id="keysInfo" action="/invitation/resume" method="post">
	<table width="100%" class="dj-form-base copy">
            <colgroup>
                <col width="250">
                <col width="*">
            </colgroup>
            <tbody>
	            <tr>
                	<input type="hidden" name="itskillsDescForm" id="itskillsDescForm">
                	<input type="hidden" name="selfEvaluationForm" id="selfEvaluationForm">
                	<input type="hidden" name="corpName" id="corpName" value="${(job.corpName)!""}">
                	<input type="hidden" name="jid" id="jid" value="${job.jid!""}" />
	                <th><em>*</em>&nbsp;手&nbsp;&nbsp;机:</th>
	                <td class="input">
	                	<input type="hidden" id="hidden_mobile" name="hidden_mobile" />
	                    <input type="hidden" id="hidden_old_mobile" value="<#if invitationApply?? && invitationApply.mobile?? && invitationApply.mobile!="">${(invitationApply.mobile)}</#if>" />
	                    <input type="text" class="text J_checkContact" name="mob" maxlength="11" 
	                    	value="<#if invitationApply?? && invitationApply.mobile?? && invitationApply.mobile!="">${(invitationApply.mobile)?substring(0,7)}</#if>"
	                           style="width:154px;" reg="fun:mobile" id="mobile" validated="false">
	                    <span id="span_securitycode" >
	                    		验证码：<input type="text" class="text" name="securitycode" maxlength="6" id="securitycode" 
	                    				style="width:54px;" blackValue="验证码"  />
	                    	<span id="span_securitycode_tips"><font color="gray"><a href="javascript:void(0)">已发送</a></font></span>
	                    </span>
	                    <span id="span_securitycode_pass" style="display: none;"><font color="green">已验证通过</font></span>
	                    <div style="display: none;" class="error" id="error_mobile">请输入正确的手机号码</div>
	                    <div style="display: none;" class="error" id="error_mobile_validate">请验证手机号码</div>
	                </td>
	            </tr>
	            <tr>
	                <th><em>*</em>&nbsp;邮&nbsp;&nbsp;箱:</th>
	                <td class="input">
	                    <input type="text" class="text J_checkContact" name="email" maxlength="50" value="${(invitationApply.email)!}"
	                           style="width:154px;" reg="fun:email" id="email">
	                    <div style="display: none;" class="error" id="error_email">请输入正确的邮箱地址</div>
	                </td>
	            </tr>
	            <tr>
	                <th><em>*</em>&nbsp;姓&nbsp;&nbsp;名:</th>
	                <td class="input">
				        <input type="text" autocomplete="off" id="name" style="width:154px;"
				               class="text J_checkBase J_able_b" name="name" reg="^([\u4e00-\u9fa5]){2,5}$" ajaxreg="name:namecallback" ajaxcheck="true"
				               maxlength="5" value="${(invitationApply.basicInfo.name)!}">
				        <div style="display:none;" class="error" id="error_name">请填写真实姓名，2-5个汉字</div>
	                </td>
	            </tr>
	            <tr>
				    <th><em>*</em>现居地:</th>
				    <td id="livecity-linkup">
				    <#assign livecityParentId = 0 />
				    <#assign livecityId = 0 />
				    <#if invitationApply?? && invitationApply.basicInfo?? && invitationApply.basicInfo.livecity??>
				        <#assign livecityParentId = (dictMap.DICT_CITY.map.get(invitationApply.basicInfo.livecity).parentId)!0 />
				        <#assign livecityId = invitationApply.basicInfo.livecity />
				    </#if>
				        <select style="width:80px" class="J_checkBase city" id="basic-livecity-parent">
				            <option value="">请选择</option>
				        <#list dictMap.DICT_CITY.data as item>
				            <#if item.id lt 910000>
				                <option value="${item.id?c}"<#if livecityParentId==item.id || livecityId==item.id> selected</#if>>${item.name}</option>
				            </#if>
				        </#list>
				        </select>
				        <select style="width:80px" name="livecity" class="J_checkBase city" id="basic-livecity-select">
				        <#if livecityId!=0 && dictMap.DICT_CITY.map.get(livecityId)??>
				            <#if livecityParentId!=0>
				                <#assign itemList = dictMap.DICT_CITY.map.get(livecityParentId).children />
				            <#else>
				                <#assign itemList = dictMap.DICT_CITY.map.get(livecityId).children />
				            </#if>
				            <#if itemList?size==0>
				                <option value="${livecityId}">${dictMap.DICT_CITY.map.get(livecityId).name}</option>
				            <#else>
				                <#list itemList as item>
				                    <option value="${item.id?c}"<#if livecityId == item.id> selected</#if>>${item.name}</option>
				                </#list>
				            </#if>
				        </#if>
				        </select>
				        <em class="sync"></em>
				        <script type="text/javascript">
				            $('#livecity-linkup').linkup({type: 'city'});
				        </script>
				        <div style="display: none;" class="error" id="error_livecity">请选择目前居住地</div>
				    </td>
				</tr>
            </tbody>
       </table>
       </form>	
       
       	
		<iframe id="J_UploadFrame" name="J_UploadFrame" style="display: none;"></iframe>	
       	<form target="J_UploadFrame" id="J_ImageForm" enctype="multipart/form-data" method="post"   action="http://fs1u.dajie.com/file/upload.php" style="display: none;">
		    <input type="hidden" id="needToRotate" name="needToRotate" value="0"/>
		    <input id="J_InputFile" hidefocus="true" name="file" class="upload-pic-input" type="file" />
		    <input type="hidden" id="J_InputType" name="type" value="file"/>
		    <input id="J_imgFormSubmit" name="submit" type="submit" value="上传文件">
		</form>
		
	  </div>
	<br/>
</div>
<div style="text-align:center">
	<a href="javascript:void(0);" class="fresh formValidateSubmit margin" id="J_resumeInfo" 
		itemtype="resumeInfo" onclick="submitResume()"><span>下一步</span></a>
</div>
</br>
</br>
</div>
</@page>

<style type="text/css"> 
<!--  
html{font-family:Arial,Helvetica,sans-serif,"宋体"}
.dj-main2 
{
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #CCCCCC;
    box-shadow: 2px 2px 2px rgba(175, 175, 175, 0.35);
    padding: 10px 60px;
    width:760px;
    margin-left: 40px;
    margin-bottom: 50px;
}

.dj-main3 {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #CCCCCC;
    box-shadow: 2px 2px 2px rgba(175, 175, 175, 0.35);
    margin: 35px;
    padding-left: 62px;
    padding-right: 62px;
    padding-top: 60px;
    width: 760px;
}



.dj-nosubnav2 
{
    height: 5px;
    margin-top: 24px;
    width:760px;
    margin-left: 40px;
}

.invite-title2 
{
    background: none repeat scroll 0 0 #FFFFFF;
    border-bottom: 1px solid #CAD5DA;
    height: 55px;
    padding: 10px 0;
    position: relative;
}
--> 
</style>
<script type="text/javascript">
	var submitResume = function()
	{
		var isok = 1;
		if($("#mobile").val().length != 11)
		{
			$("#error_mobile").show();
			isok = 0;
		}else
		if($("#span_securitycode_pass").is(":hidden") )
		{
			$("#error_mobile_validate").show();
			isok = 0;
		}
		if($("#name").val()=="" )
		{
			$("#error_name").show();
			isok = 0;
		}
		if($("#email").val()=="" )
		{
			$("#error_email").show();
			isok = 0;
		}
		if($("#basic-livecity-select").val()==null || $("#basic-livecity-select").val()=="")
		{
			$("#error_livecity").show();
			isok = 0;
		}
		if( isok == 1)
		{
			$("#keysInfo").submit();
		}
	}
	/*
	$("#mobile").keyup(function()
	{
		eventForMobile()
	})*/
	
	$("#mobile").change(function()
	{
		eventForMobile();
	});
	$("#mobile").focus(function()
	{
		$("#error_mobile").hide();
	});
	
	$("#name").blur(function()
	{
		eventForName();
	});
	$("#name").focus(function()
	{
		$("#error_name").hide();
	});
	
	var eventForName = function()
	{
		var reg = /^([\u4e00-\u9fa5]){2,5}$/;
		
		if(reg.test($("#name").val()))
		{
			$("#error_name").hide();
		}else
		{
			$("#error_name").show();
		}
	};
	
	var eventForMobile = function()
	{
		if($("#mobile").val() == $("#hidden_old_mobile").val())
		{
    		$("#span_securitycode_pass").show();
			return;
		}
		if($("#mobile").val().length == 11 )
		{
			if($("#hidden_mobile").val() != $("#mobile").val())
			{
				$("#hidden_mobile").val($("#mobile").val());
				$("#mobile").attr("validated","false");
			}
			if($("#mobile").attr("validated")=="false")
			{
				var email = $("#email").val();
				validateMobile($("#mobile").val(),email);
			}
		}else
		{
        	$("#span_securitycode").hide();
			$("#hidden_mobile").val($("#mobile").val());
		}
	}

	var validateMobile = function(mobile,email)
	{
			if($("#mobile").val() == $("#hidden_old_mobile").val())
			{
				$("#span_securitycode_pass").show();
				return ;
			}
			 //验证保存手机号码
            $.ajax({url: '/ajax/validatemobile',
                type: 'POST',
                data:{mobile: mobile,email:email},
                dataType: 'text',
                timeout: 5000,
                error: function()
                { 
                	//alert("error");
                },
                success: function(result)
                {
                	res = eval(result);
                	if(res.result == -1)
                	{
                		$("#error_mobile").show();
                	}else if(res.result == 0)
                    {	
                    	showSecurity(res);
                    }else if(res.result == 1)
                    {
                    	showSecurityPass(res);
                    }else if(res.result == 2)
                    { 
                    	showSecurityHide();
                    }else
                    { 
                    }
                    
                }
            });
	}
	
	
	$("#span_securitycode").hide();
	$("#securitycode").keyup(function()
	{
		if($("#securitycode").val().length==6 && !$("#span_securitycode").is(":hidden"))
		{	
			checksecuritycode($("#securitycode").val());
		}
	})
	
	var checksecuritycode = function(v)
	{
		{	var checked = 1;
			if(!$("#span_securitycode_pass").is(":hidden") )
			{
				checked = 0;
			}
		     $.ajax({url: '/ajax/checksecuritycode',
                type: 'POST',
                data:{mobile: $("#mobile").val(),email:$("#email").val(),code:v,checked:checked},
                dataType: 'text',
                timeout: 5000,
                error: function()
                { 
                	//alert("error");
                },
                success: function(result)
                {
                	res = eval(result);
                    if(res.result == 1)
                    {
                    	showSecurityPass(res);
                    }else
                    {
                    	$("#span_securitycode_tips").show();
                    	$("#span_securitycode_tips").html("<font color='red'>验证码错误</font>");
                    }
                }
            });
       }
	}

	$("#email").change(function()
	{
		if($("#mobile").val() == $("#hidden_old_mobile").val())
			{
				$("#span_securitycode_pass").show();
				return ;
			}
		$("#error_email").hide();
		if($("#email").val() != "")
		{
			checkemail($("#email").val());
		}
	})

	var checkemail = function(email)
	{
		var checked = 1;
		if($("#span_securitycode_pass").is(":hidden"))
		{
			checked = 0;
		} else
		{
			return;
		}
		$.ajax(
		{
			url:"/ajax/checkemail",
			type:"POST",
			data:{email:email,mobile:$("#mobile").val(),checked:checked},
			dateType:"text",
			timeout:5000,
			error:function()
			{
				//alert("error");
			},
			success:function(result)
			{
				res = eval(result);
				if(res.result == -1)
				{
					$("#error_email").show();
				}else if(res.result == 0)
				{
					showSecurity(res);
				}else if(res.result == 1)
				{
					showSecurityPass(res);
				}else if(res.result == 2)
				{
					showSecurityHide();
				}else
				{
					$("#error_email").hide();
				}
			}
		});
	}

	var showSecurity = function(json)
	{
		if($("#mobile").val() == $("#hidden_old_mobile").val())
			{
				$("#span_securitycode_pass").show();
				return ;
			}
		$("#error_mobile").hide();
    	$("#span_securitycode").show();
    	$("#span_securitycode_tips").html("<font color='gray' id='timer'>已发送:100s</font>");
    	timerclock(60);
    	$("#securitycode").val("");
    	$("#span_securitycode_pass").hide();
    	if($("#hidden_old_mobile").val() != $("#mobile").val() && json.is_login == 0)
    	{
        	$("#name").val('');
        	$("#basic-livecity-parent option[value='']").attr("selected",true);
        	$("#basic-livecity-select option").remove();
    	}
	}
	
	var timerclock = function (sec)
	{
		sec = sec -1 ;
		if(sec == 0)
		{
		 	$("#span_securitycode_tips").html("<a href='javascript:void(0)' onclick='getsecurity()'>重新获取</font>");
		 	return;
		}
		$("#span_securitycode_tips").html("<font color='gray' id='timer'>已发送:"+sec+"s</font>");
		setTimeout("timerclock("+sec+")",1000);
	}
	
	var getsecurity = function()
	{
		var mobile = $("#mobile").val();
		if(mobile != "")
		{
			getsecurityajax(mobile);
			timerclock(60);
		}else
		{
			$("#error_mobile").show();
		}
	}
	
	var getsecurityajax = function(mobile)
	{
		$.ajax({
			url:'/ajax/getsecuritycode',
			type:'POST',
			data:{mobile:mobile},
			dataType: 'text',
			timeout: 5000,
			async : true,
			error:function(){  },
			success:function(r)
			{	
			}	
		});
	}
	
	var showSecurityHide = function()
	{
		$("#mobile").attr("validated","true");
    	$("#securitycode").val("");
    	$("#error_mobile").hide();
    	$("#span_securitycode").hide();
    	$("#securitycode").val("");
    	$("#error_mobile_validate").hide();
	}
	
	var showSecurityPass = function(res)
	{ 
		showSecurityHide();
    	$("#span_securitycode_pass").show();
    	if(res.is_login == 0 || true)
    	{
	    	$("#name").val(res.name);
	    	$("#basic-livecity-parent option[value='"+res.livecity_parent+"']").attr("selected",true);
    	 	if(res.livecity == '')
    	 	{
    	 		$("#basic-livecity-select option").remove();
    	 	}else
    	 	{
		    	$.ajax({
						url:'/ajax/dict',
						type:'POST',
						data:{type:'city',id:res.livecity_parent},
						dataType: 'text',
						timeout: 5000,
						async : true,
						error:function(){},
						success:function(r)
						{	
						 	rs = eval(r);
							$(rs).each(function(i,o) 
							{ 
									$("#basic-livecity-select").append("<option value='"+o.id+"'>"+o.text+"</option>");
							});
		    				$("#basic-livecity-select option[value='"+res.livecity+"']").attr("selected", true);
						}	
					});
				}
		}
	}

	$("#basic-livecity-select").change(function()
	{
		$("#error_livecity").hide();
		/*save livecity
		if($("#basic-livecity-select") != "")
		{
			$.ajax({
				url:'/ajax/savelivecity',
				type:'POST',
				data:{livecity:$("#basic-livecity-select").val(),uid:1},
				dataType: 'text',
				timeout: 5000,
				error:function(){},
				success:function(){}
			});
		}
		*/
	});


	 $(".js-uploadImg").die().live("click",function()
    {      
        var inputType = $(this).attr("inputType");
        $("#J_InputType").val("file");
        relId = $(this).attr("relImgId");
        $("#J_InputFile").click();
        $("#J_InputFile").die().live("change",function(){
	         $("#J_imgFormSubmit").click();
        });
    });

	function UPLOAD_CALLBACK(r) 
    {
    	if(r.startWith("http"))
    	{
    		if(r.endWith("rar") || r.endWith("zip"))
    		{
    			alert("上传文件类型错误，支持doc,docx,xls,ppt,xlsx,pptx,pdf,jpg,png,txt 类型文件！");
    		}else
    		{
				$("#resumeFileName").show();
				//$("#resumeFileUpload").hide();
				$("#inputResumeFile").val(r);
    		}
		}else
		{
    			alert("上传文件类型错误，支持doc,docx,xls,ppt,xlsx,pptx,pdf,jpg,png,txt 类型文件！");
		}
	};
	String.prototype.endWith=function(s)
	{
	  if(s==null||s==""||this.length==0||s.length>this.length)
	     return false;
	  if(this.substring(this.length-s.length)==s)
	     return true;
	  else
	     return false;
	  return true;
	 }
	
	 String.prototype.startWith=function(s)
	 {
	  if(s==null||s==""||this.length==0||s.length>this.length)
	   return false;
	  if(this.substr(0,s.length)==s)
	     return true;
	  else
	     return false;
	  return true;
	 }
	function deleteResume()
	{
		$("#resumeFileName").hide();
		//$("#resumeFileUpload").show();
		$("#inputResumeFile").val("");
	}

	$(function()
	{  
   	 	//$("#resume").show();  
	});

	$('.resume_hide').click(function(){
		$("#resume").hide();
	});
	
	$('.resume_show').click(function(){
		$("#resume").show();
	});

    $('.J_perfectResume').click(function(){
        $.dialog('#perfect-dialog', {mask:true, mercy: false,defbtn:false, title:'完善简历提示', width:480,oncomplete:function(e){
            $.dialog('#upload-dialog', {mask:true, mercy: false,defbtn:false,customClass:'upload-dialog', title:'更新简历提示', width:480,oncomplete:function(){
                window.location.reload(true);
            }
            })
        }});
    });

    $('#J_formSubmit').click(function(){
        if($(this).hasClass('disable')){
            $('.letter-t').addClass('textarea-error');
        }else{
            var save = ($('#saveCheck').attr("checked") == true) ? 1 : 0 ;
            if($('#letterContent').val() == '点击这里填写求职信(3-300字)'){
                $('#letterContent').val('');
            }

            var letter = $('#letterContent').val();
            if($(this).hasClass('disable')){//字数不符合条件直接返回
                $('#letterContent').css('border-color','#f00');
                return;
            }

            //需要验证是否有敏感词
            $.ajax({url: '/jobapply/confirm',
                type: 'POST',
                data:{content: letter, save : save,jid:$('#jid_1').val(), id : $('#id').val(), applytype : $('#applytype').val(), jobtype : $('#jobtype').val()},
                dataType: 'text',
                timeout: 5000,
                error: function(){alert('发送简历失败,请刷新后重试');},
                success: function(result){
                    var code = result.substr(0, 1);
                    if(code == 0){//保存求职信成功
                        hrViewProfileAlertAndSubmit();
                    }else{//code ==1保存求职信失败
                        alert(result.substring(2));
                    }
                }
            });
        }
    });

    function hrViewProfileAlertAndSubmit(){
        $.ajax({url: '/jobapply/hrViewProfileAlert',
            type: 'GET',
            dataType: 'text',
            timeout: 3000,
            error: function(){nextLocation()},
            success: function(result){
                var code = result.substr(0, 1);
                if(code != 0){
                    $.dialog('#send-dialog', {mask:true, mercy: false, defbtn:false,customClass:'upload-dialog', title:'发送简历提示', width:480,oncomplete:function(){
                        nextLocation();
                    },onabort:function(){
                        nextLocation();
                    }});
                }else{
                    nextLocation();
                }

            }
        });
    }

    function nextLocation()
    {
        document.location.href = "/invitation/success?id=${id!""}&jid=${jid!""}";
    }
    
    
     
    
</script>